Skip to content

Add adapter conformance test suite#2664

Open
paulteehan wants to merge 4 commits into
mainfrom
feat/adapter-conformance-tests
Open

Add adapter conformance test suite#2664
paulteehan wants to merge 4 commits into
mainfrom
feat/adapter-conformance-tests

Conversation

@paulteehan
Copy link
Copy Markdown
Contributor

@paulteehan paulteehan commented Apr 14, 2026

Summary

AI-written.

Adapter conformance test suite — 65 integration tests across 3 new files that catch field bugs at the adapter contract layer. Plus two adapter source fixes for real bugs the suite found.

  • test_conformance_identifiers.py (24 tests) — reserved SQL words, hyphens, mixed-case as column names; end-to-end DDL+DML+contract checks; parametrized quoting consistency.
  • test_conformance_discovery.py (9 tests) — internal object filtering, view/MV contract checks, type round-trip for all SodaDataTypeNames, synonym bidirectionality, column type parameters (precision/scale/length).
  • test_conformance_types_dialect.py (32 tests) — missing check per data type, aggregate per numeric type, schema check, sampling SQL execution per sampler, regex via invalid check, RANDOM() value range, forward/reverse type mapping, synonym consistency.

Designed to catch the top 3 categories of field bugs: identifier quoting (~30%), metadata discovery (~20%), and type mapping/dialect (~18%).

Bugs found and fixed

While running this suite across all adapters, the synonym bidirectionality test found two real bugs in the synonym definitions. Both are fixed in this PR:

  • Redshift (soda-redshift/.../redshift_data_source.py): float was declared a synonym of real/float4, but its reverse mapping correctly resolves it to DOUBLE (it is an alias for float8/double precision). Fix: move float out of ["real", "float4"] and into [REDSHIFT_DOUBLE_PRECISION, "float8", "float"].
  • DuckDB (soda-duckdb/.../duckdb_data_source.py): two synonym groups lumped together types that map to different SodaDataTypes — all integer types were grouped with decimal/numeric, and single-precision floats were grouped with double-precision floats. Fix: split into nine correct synonym groups; drop names that aren't DuckDB types (number, byteint, timestamp_ntz, timestamp_ltz).

Other changes from review

  • Relaxed datetime_precision == N to >= N in test_column_type_parameters_preserved. Trino connectors (e.g. iceberg) normalize datetime precision to a connector-specific default (often 6) regardless of DDL — the relaxed check still catches "no precision returned at all" while accepting normalization.
  • Case-insensitive identifier preservation check in test_ddl_and_dml_quoting_both_preserve_identifier — some dialects fold case during quoting.
  • Dropped two redundant private-API tests (test_sampling_sql_generation, test_regex_sql_generation) — coverage is preserved by the end-to-end tests in the same file. Remaining private-API uses (_get_data_type_name_synonyms, _data_type_name_synonym_mappings) are kept with explanatory comments because no public accessor exists for the synonym table itself.
  • Removed gratuitous always-true assertions (assert result is not None on a typed return, assert len(rows) >= 0).

Results per adapter (latest CI on this branch)

To be updated once CI completes. Prior run was 620 passed / 46 skipped / 1 failed (Redshift float synonym, now fixed). DuckDB and Trino-S3 also failed and are now fixed.

Test plan

  • All conformance tests pass on DuckDB locally (61/64, 3 capability skips)
  • CI green on duckdb, redshift, trino-s3 after this push
  • CI green on the rest of the matrix (postgres, sqlserver, snowflake, bigquery, fabric, synapse, athena, databricks, sparkdf, trino-postgres)
  • SonarCloud quality gate — gratuitous assertions removed; will know on next analysis

🤖 Generated with Claude Code

paulteehan and others added 2 commits April 28, 2026 20:35
…lect)

67 integration tests that validate every adapter handles identifier quoting,
metadata discovery, type mapping, sampling, and regex correctly. Run against
all 10 adapters: 620 passed, 46 skipped, 1 failure (Redshift float synonym).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@paulteehan paulteehan force-pushed the feat/adapter-conformance-tests branch from 8c576f3 to 0de0c27 Compare April 28, 2026 18:36
paulteehan and others added 2 commits April 29, 2026 13:31
AI-written.

Adapter source fixes (real bugs surfaced by the synonym bidirectionality test):

- soda-redshift: move "float" out of the FLOAT synonym group and into the
  DOUBLE group. In Redshift, FLOAT is an alias for FLOAT8 / DOUBLE PRECISION,
  not for REAL / FLOAT4. The reverse mapping already had this right
  (float -> DOUBLE); the synonym group was inconsistent.
- soda-duckdb: split the catch-all integer/decimal group and the
  catch-all single+double precision float group into proper per-type
  synonym groups. Drop type names that don't exist in DuckDB
  (number, byteint, timestamp_ntz, timestamp_ltz, timestamp_tz).

Test fixes:

- test_conformance_discovery: relax datetime_precision check from == N
  to >= N. Trino connectors (e.g. iceberg) normalize datetime precision
  to a connector-specific default (often 6) regardless of DDL, which
  still satisfies the contract. Drop unused test_table local in the
  internal-table filter test. Remove unused f-string prefixes and add
  comments where dialect-internal accessors are needed.
- test_conformance_identifiers: case-insensitive identifier preservation
  check; some dialects fold case during quoting. Drop gratuitous
  "is not None" assertions on values typed as str.
- test_conformance_types_dialect: drop two redundant private-API tests
  (_build_sample_sql, _build_regex_like_sql) — coverage is preserved
  by the existing end-to-end tests in the same file. Remove gratuitous
  always-true assertions (assert result is not None on a typed return,
  assert len(rows) >= 0). Clean up unused imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI black hook collapsed two adjacent f-string literals onto one line.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@m1n0 m1n0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: conformance without context isn't clear, I had to skim through tests to understand the motivation of this PR. Would it make sense to a) rename or b) put these tests in a descriptive folder?

Copy link
Copy Markdown
Contributor

@m1n0 m1n0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thought @paulteehan - we are adding a whole bunch if e2e tests here, I am a bit worried about bloating the test suite. A lot of these e2e tests are very similar to check type tests (e.g. missing etc) just with the variation in table/column name using a special character or something like that. Wouldn't it make sense to either a) consolidate these into less tests overall or b) unit test generated queries to make sure identifiers are handled correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants